﻿using System.Collections;
using System.Collections.Generic;

using DG.Tweening;

using Entitas;

using UnityEngine;


namespace Internal
{
    /// <summary>
    /// 移动系统
    /// </summary>
    public class MoveSystem : ReactiveSystem<GameEntity>
    {

        public MoveSystem(Contexts contexts) : base(contexts.game)
        {

        }

        protected override void Execute(List<GameEntity> entities)
        {
            foreach (GameEntity entity in entities)
            {
                entity.internalView.viewTrans.DOMove(entity.internalMove.targetPos, 3);
            }
        }

        protected override bool Filter(GameEntity entity)
        {
            return entity.hasInternalMove
                && entity.isInternalMoveComplete
                && entity.hasInternalView;
        }

        protected override ICollector<GameEntity> GetTrigger(IContext<GameEntity> context)
        {
            return context.CreateCollector(GameMatcher.InternalMove);
        }
    }
}


